﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;
using System.Data;
using Components;
using ControlService;
using Newtonsoft.Json;

namespace ControlService.DataModel
{
    [DataContract]
    public class ReturnPageData : DataContractBase
    {
        private string _data;

        public ReturnPageData(int allRowCount)
        {
            this._allRowCount = allRowCount;
        }

        public ReturnPageData(int allRowCount, string data)
        {
            this._allRowCount = allRowCount;
            this._data = data;
        }

        private int _allRowCount;

        /// <summary>
        /// 总记录数
        /// </summary>
        [DataMember]
        public int AllRowCount
        {
            get { return _allRowCount; }
            set { _allRowCount = value; }
        }

        [DataMember]
        public string Data
        {
            get { return _data; }
            set { _data = value; }
        }

        public void TableToData(DataTable table)
        {
            string value = Json.TableToXml(table);
            _data = StringUtil.Zip(value);
        }

        private string _summary;

        [DataMember]
        public string Summary
        {
            get { return _summary; }
            set { _summary = value; }
        }

        public void TableToSummary(DataTable table)
        {
            string value = Json.TableToXml(table);
            _summary = StringUtil.Zip(value);
        }

    }
}
